package com.atguigu.crowd.api;

import com.atguigu.crowd.util.ResultEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.TimeUnit;

/**
 * @author cyb315
 * @create 2021-11-06 14:53
 */
@FeignClient("atguigu-crowd-redis")
public interface RedisRemoteService {

    // 向redis数据库设置key和value的远程调用接口
    @RequestMapping("/set/redis/key/value/remote")
    public ResultEntity<String> setRedisKeyValueRemote(@RequestParam("key") String key,@RequestParam("value") String value);

    // 向redis数据库设置key和value的远程调用接口,可设置超时时间和单位
    @RequestMapping("/set/redis/key/value/remote/with/timeout")
    public ResultEntity<String> setRedisKeyValueRemoteWithTimeout(
            @RequestParam("key") String key,
            @RequestParam("value") String value,
            @RequestParam("time") long time,
            @RequestParam("timeUnit") TimeUnit timeUnit
            );

    // 根据key从redis数据库获取value的远程调用接口
    @RequestMapping("/get/redis/string/value/by/key/remote")
    public ResultEntity<String> getRedisStringValueByKeyRemote(@RequestParam("key") String key);

    // 从redis里删除key的远程调用接口
    @RequestMapping("/remove/redis/key/remote")
    public ResultEntity<String> removeRedisKeyRemote(@RequestParam("key") String key);

}
